package lanqiao;

/**
 * @Project : ProgrammingExercises
 * @Package : LanQiao.PrepareForCompetition
 * @File : Q0175.java
 * @Author : WangRuoyu
 * @Date : 2023/3/16 11:37
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Q0175 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] words = br.readLine().split(" ");

        int n = Integer.parseInt(words[0]);

        for (int i = 0; i < n; ++i) {
            String[] go = br.readLine().split(" ");
            String[] come = br.readLine().split(" ");

            int go1Second = Integer.parseInt(go[0].substring(0, 2)) * 3600 + Integer.parseInt(go[0].substring(3, 5)) * 60 + Integer.parseInt(go[0].substring(6, 8));
            int go2Second = Integer.parseInt(go[1].substring(0, 2)) * 3600 + Integer.parseInt(go[1].substring(3, 5)) * 60 + Integer.parseInt(go[1].substring(6, 8));
            if (go.length == 3) {
                int day = Integer.parseInt(go[2].substring(2, 3));
                go2Second += day * 24 * 3600;
            }

            int come1Second = Integer.parseInt(come[0].substring(0, 2)) * 3600 + Integer.parseInt(come[0].substring(3, 5)) * 60 + Integer.parseInt(come[0].substring(6, 8));
            int come2Second = Integer.parseInt(come[1].substring(0, 2)) * 3600 + Integer.parseInt(come[1].substring(3, 5)) * 60 + Integer.parseInt(come[1].substring(6, 8));
            if (come.length == 3) {
                int day = Integer.parseInt(come[2].substring(2, 3));
                come2Second += day * 24 * 3600;
            }

            int time = (come2Second - come1Second + go2Second - go1Second) / 2;

            System.out.printf("%02d:%02d:%02d\n", time / 3600, time % 3600 / 60, time % 3600 % 60);
        }
    }
}
